1. Technical Field
This invention generally relates to computer systems and more specifically relates to an apparatus and method for locking files in a computer system.
2. Background Art
Since the dawn of the computer era, computer systems have evolved into extremely sophisticated devices that may be found in many different settings. Computer systems typically include a combination of hardware (e.g., semiconductors, circuit boards, etc.) and software (e.g., computer programs). As advances in semiconductor processing and computer architecture push the performance of the computer hardware higher, more sophisticated computer software has evolved to take advantage of the higher performance of the hardware, resulting in computer systems today that are much more powerful than just a few years ago.
Computer programs sometimes need to read or write a file without the threat of the file being changed during the read or write. File locking schemes have been developed to allow a computer program to lock a file before accessing the file, thereby protecting the file from being accessed by other computer programs while the file is locked. Once the file is unlocked, computer programs can access the file as needed, and may set the lock on the file before accessing the file as required.
Locking schemes have been incorporated into operating systems to relieve software applications of the burden of implementing locking schemes, and to provide a secure manner in handling file locking that cannot be altered or disabled by a computer program. For example, personal computer operating systems, such as IBM""s OS/2 and Microsoft Windows, use 32 or 64 bit locks to lock a file or portion of a file. In another example, IBM""s OS/400 operating system for the AS/400 computer implements a 64 bit signed lock, but ignores all negative lock addresses, resulting in 63 bits of addressable lock addresses.
Some computer systems may need to provide locking to different computer programs that expect different sized locks. For example, the OS/400 operating system needs to be able to service file locking for Unix applications that use 63 bit locks as well as file locking for PC applications that use 64 bit locks. However, this mismatch between expected size of locks introduces a problem, because any lock of an address above 63 bits cannot be recognized by Unix applications that only expect 63 bit locks. Without a way to provide a locking scheme that can service different size locks, operating systems will continue to have potential problems when servicing computer programs that use different size locks.
According to the preferred embodiments, an apparatus and method provide a locking scheme that accommodates different size file locks. A first file lock command, referred to as an M bit file lock command, assumes a lock with a length of M bits. A second lock command, referred to as an N bit file lock command, assumes a lock with a length of N bits, which is less than M bits. A translation mechanism services both M-bit and N-bit file lock commands, and accesses locks that are M bits in length in response to both M-bit and N-bit file lock commands. The address range between 2N and 2Mxe2x88x921 are assigned to one or more corresponding control addresses in the address range of 0 to 2Nxe2x88x921. Locking of any control address using an N bit file lock command results in the address range between 2N and 2Mxe2x88x921 being automatically locked in addition to the addresses specified in the N bit file lock command. This allows translating an N bit file lock command to an M bit lock. Similarly, when an M bit file lock command locks any address between 2N and 2Mxe2x88x921, the translation mechanism locks the address or addresses specified in the M bit file lock command, and in addition locks the control address or addresses that correspond to the specified address. In this manner, both N bit and M bit file lock commands may access the same M bit locks, assuring that proper locking is maintained between computer programs that use N bit locks and computer programs that use M bit locks.
The foregoing and other features and advantages of the invention will be apparent from the following more particular description of preferred embodiments of the invention, as illustrated in the accompanying drawings.